package com.example.springbootagain.controller;

import com.example.springbootagain.entity.User;
import com.example.springbootagain.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
public class UserController {




    @Resource
    private UserService userService;


    @GetMapping("/getAllUser")
    public List<User> getAllUser() {
        return userService.ServiceSelectAllUser();
    }
    @GetMapping("/getOneUser/{uid}")
    public User getOneUser(@PathVariable String uid){
        return userService.SerViceSelectOneUser(uid);
    }
    @GetMapping("/login/{username}/{password}")
    public User login(@PathVariable String username, @PathVariable String password){
        return userService.ServiceSelectLogin(username,password);
    }
    @PostMapping("/reg")
    public int reg(@RequestBody User user) {
        int res = userService.ServiceInsertUser(user);
        return res;
    }
    @PatchMapping("/updatePassword")
    public void updatePassword(@RequestBody User user){
        userService.ServiceUpdatePassword(user);
    }
    @DeleteMapping("/deleteUser")
    public void deleteUser(@RequestBody User user){
        userService.ServiceDeleteUser(user);
    }
}
